package com.cheer.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author cheer
 */
@Repository
public class LotteryCacheDao {

    private static final String ANNOUNCEMENT_KEY = "net:match:announcement";

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public List<String> getAnnouncement() {
        return stringRedisTemplate.opsForList().range(ANNOUNCEMENT_KEY, 0, 9);
    }

    public void addAnnouncement(String announcement) {
        stringRedisTemplate.opsForList().leftPush(ANNOUNCEMENT_KEY, announcement);
    }

    public void trimAnnouncement() {
        stringRedisTemplate.opsForList().trim(ANNOUNCEMENT_KEY, 0, 19);
    }
}
